var app = getApp();
var com = require('../../common.js');
Page({
  data: {
    tap: 0,
    kid: 0,
    statusd: 1
  },
  onLoad: function (options) {
    var _this = this
    _this.setData({
      search: options.search
    })
    _this.groupsOrderInfo(options.search, '', '', '')
  },
  onReady: function () { },
  onShow: function () { },
  onHide: function () { },
  onUnload: function () { },
  onPullDownRefresh: function () { },
  onReachBottom: function () { },
  onShareAppMessage: function () { },
  //查看订单
  groupsOrderInfo(supplier, state, consignee, search) {
    var _this = this
    com.link(app.link.groupsOrderInfo, {
      supplier: supplier,
      state: state,
      consignee: consignee,
      search: search,
    }, function (res) {
      console.log(res);
      _this.setData({
        orderlist: res.data.data,
        statusd: 0
      })
    }, "GET")
  },
  groupsOrder(store) {
    var _this = this
    com.link(app.link.groupsOrder, {
      store: store
    }, function (res) {
      console.log(res)
      _this.setData({
        orderlist: res.data.data,
        statusd: 0
      })
    }, "GET")
  },
  //切换tap
  onTapPage() {
    var _this = this,
      tap = _this.data.tap == 1 ? 0 : 1
    _this.setData({
      statusd: 1
    })
    if (tap == 0) {
      _this.groupsOrderInfo(_this.data.search, '', '', '')
    } else {
      _this.groupsOrder(_this.data.search)
    }
    _this.setData({
      tap: tap
    })
  },
  nav_top(e) {
    var _this = this,
      statelist = "",
      kid = ""
    _this.setData({
      statusd: 1
    })
    if (e.currentTarget.dataset.kid == 0) {
      kid = e.currentTarget.dataset.kid
      statelist = ''
    } else if (e.currentTarget.dataset.kid == 1) {
      kid = e.currentTarget.dataset.kid
      statelist = 'pay'
    } else if (e.currentTarget.dataset.kid == 2) {
      kid = e.currentTarget.dataset.kid
      statelist = 'deliver'
    } else if (e.currentTarget.dataset.kid == 3) {
      kid = e.currentTarget.dataset.kid
      statelist = 'receiving'
    } else if (e.currentTarget.dataset.kid == 4) {
      kid = e.currentTarget.dataset.kid
      statelist = 'complete'
    } else if (e.currentTarget.dataset.kid == 5) {
      kid = e.currentTarget.dataset.kid
      statelist = 'cancel'
    } else if (e.currentTarget.dataset.kid == 6) {
      kid = e.currentTarget.dataset.kid
      statelist = 'after'
    }
    _this.setData({
      kid: kid,
      statelist: statelist
    })
    _this.groupsOrderInfo(_this.data.search, statelist, '', '')
  },
})